package cn.iot.controller.sys;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.entity.SysGateway;
import cn.iot.sys.service.SysGatewayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/sys/gateway")
public class SysGatewayController {
    @Resource
    private SysGatewayService sysGatewayService;
    private Logger logger = LoggerFactory.getLogger(getClass());

    @PostMapping("getSysGatewayList")
    private ResultMsg getSysGatewayList(@RequestParam Map<String,Object> map){
        logger.info("SysGatewayController getSysGateway map{}",map);
        ResultMsg msg = sysGatewayService.getSysGatewayList(map);
        logger.debug("SysGatewayController getSysGateway msg{}",msg);
        return msg;
    }

    @PostMapping("addSysGateway")
    public ResultMsg addSysGateway(@RequestBody SysGateway sysGateway){
        logger.info("SysGatewayController addSysGateway sysGateway{}",sysGateway);
        ResultMsg msg = sysGatewayService.addSysGateway(sysGateway);
        logger.debug("SysGatewayController addSysGateway msg{}",msg);
        return msg;
    }

    @PostMapping("updGatewayById")
    public ResultMsg updGatewayById(@RequestBody SysGateway sysGateway){
        logger.info("SysGatewayController updGatewayById sysGateway{}",sysGateway);
        ResultMsg msg = new ResultMsg();
//        ResultMsg msg = sysGatewayService.updGatewayById(sysGateway);
        logger.debug("SysGatewayController updGatewayById msg{}",msg);
        return msg;
    }

    @PostMapping("delGatewayById")
    public ResultMsg delGatewayById(@RequestParam int id){
        logger.info("SysGatewayController delGatewayById id{}",id);
        ResultMsg msg = sysGatewayService.delGatewayById(id);
        logger.debug("SysGatewayController delGatewayById msg{}",msg);
        return msg;
    }
}
